package com.edu.exam.entity.exampaper.review;

import com.edu.exam.enums.grading.ConfigType;
import com.edu.exam.enums.assessment.generation.Scope;
import com.edu.exam.enums.examination.paper.AlgorithmType;
import com.edu.exam.enums.exampaper.review.ExamPaperCheckTaskStatus;
import com.edu.exam.enums.grading.StatType;
import com.edu.exam.enums.grading.StatDimension;
import com.edu.exam.enums.exampaper.review.StatPeriod;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 试卷查重统计实体类
 *
 * <p>记录试卷查重的统计数据，包括查重次数、成功率、平均相似度、
 * 时间分布等统计信息。支持多维度统计分析和报表生成。</p>
 *
 * @author 系统生成
 * @version 2.0
 * @since 2025-11-09
 */
@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class ExamPaperCheckStatistics {

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 统计日期
     */
    @Column(name = "stat_date", nullable = false)
    private LocalDate statDate;

    /**
     * 统计类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "stat_type", nullable = false, length = 20)
    private StatType statType;

    /**
     * 统计维度
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "stat_dimension", nullable = false, length = 20)
    private StatDimension statDimension;

    /**
     * 部门ID
     */
    @Column(name = "department_id")
    private Long departmentId;

    /**
     * 部门名称
     */
    @Column(name = "department_name", length = 200)
    private String departmentName;

    /**
     * 创建人ID
     */
    @Column(name = "creator_id")
    private Long creatorId;

    /**
     * 创建人姓名
     */
    @Column(name = "creator_name", length = 100)
    private String creatorName;

    /**
     * 总查重次数
     */
    @Column(name = "total_check_count")
    private Integer totalCheckCount;

    /**
     * 成功查重次数
     */
    @Column(name = "success_check_count")
    private Integer successCheckCount;

    /**
     * 失败查重次数
     */
    @Column(name = "failed_check_count")
    private Integer failedCheckCount;

    /**
     * 成功率
     */
    @Column(name = "success_rate", precision = 5, scale = 2)
    private BigDecimal successRate;

    /**
     * 单卷查重次数
     */
    @Column(name = "single_check_count")
    private Integer singleCheckCount;

    /**
     * 批量查重次数
     */
    @Column(name = "batch_check_count")
    private Integer batchCheckCount;

    /**
     * 交叉查重次数
     */
    @Column(name = "cross_check_count")
    private Integer crossCheckCount;

    /**
     * 总试卷数量
     */
    @Column(name = "total_paper_count")
    private Integer totalPaperCount;

    /**
     * 高相似度试卷数量
     */
    @Column(name = "high_similarity_count")
    private Integer highSimilarityCount;

    /**
     * 中等相似度试卷数量
     */
    @Column(name = "medium_similarity_count")
    private Integer mediumSimilarityCount;

    /**
     * 低相似度试卷数量
     */
    @Column(name = "low_similarity_count")
    private Integer lowSimilarityCount;

    /**
     * 平均相似度
     */
    @Column(name = "average_similarity", precision = 5, scale = 2)
    private BigDecimal averageSimilarity;

    /**
     * 最高相似度
     */
    @Column(name = "max_similarity", precision = 5, scale = 2)
    private BigDecimal maxSimilarity;

    /**
     * 最低相似度
     */
    @Column(name = "min_similarity", precision = 5, scale = 2)
    private BigDecimal minSimilarity;

    /**
     * 相似度中位数
     */
    @Column(name = "median_similarity", precision = 5, scale = 2)
    private BigDecimal medianSimilarity;

    /**
     * 超过阈值的试卷数量
     */
    @Column(name = "threshold_exceeded_count")
    private Integer thresholdExceededCount;

    /**
     * 阈值超标率
     */
    @Column(name = "threshold_exceed_rate", precision = 5, scale = 2)
    private BigDecimal thresholdExceedRate;

    /**
     * 总执行时间(毫秒)
     */
    @Column(name = "total_execution_time")
    private Long totalExecutionTime;

    /**
     * 平均执行时间(毫秒)
     */
    @Column(name = "average_execution_time")
    private Long averageExecutionTime;

    /**
     * 最短执行时间(毫秒)
     */
    @Column(name = "min_execution_time")
    private Long minExecutionTime;

    /**
     * 最长执行时间(毫秒)
     */
    @Column(name = "max_execution_time")
    private Long maxExecutionTime;

    /**
     * 总处理题数
     */
    @Column(name = "total_question_count")
    private Integer totalQuestionCount;

    /**
     * 重复题数
     */
    @Column(name = "duplicate_question_count")
    private Integer duplicateQuestionCount;

    /**
     * 重复率
     */
    @Column(name = "duplication_rate", precision = 5, scale = 2)
    private BigDecimal duplicationRate;

    /**
     * 按题型统计
     */
    @Column(name = "question_type_stats", columnDefinition = "TEXT")
    private String questionTypeStats;

    /**
     * 按难度统计
     */
    @Column(name = "difficulty_stats", columnDefinition = "TEXT")
    private String difficultyStats;

    /**
     * 按知识点统计
     */
    @Column(name = "knowledge_point_stats", columnDefinition = "TEXT")
    private String knowledgePointStats;

    /**
     * 按时间段统计
     */
    @Column(name = "time_period_stats", columnDefinition = "TEXT")
    private String timePeriodStats;

    /**
     * 按算法版本统计
     */
    @Column(name = "algorithm_version_stats", columnDefinition = "TEXT")
    private String algorithmVersionStats;

    /**
     * 热点试卷统计
     */
    @Column(name = "hot_paper_stats", columnDefinition = "TEXT")
    private String hotPaperStats;

    /**
     * 异常情况统计
     */
    @Column(name = "abnormal_stats", columnDefinition = "TEXT")
    private String abnormalStats;

    /**
     * 趋势分析数据
     */
    @Column(name = "trend_analysis", columnDefinition = "TEXT")
    private String trendAnalysis;

    /**
     * 对比分析数据
     */
    @Column(name = "comparison_analysis", columnDefinition = "TEXT")
    private String comparisonAnalysis;

    /**
     * 预测分析数据
     */
    @Column(name = "prediction_analysis", columnDefinition = "TEXT")
    private String predictionAnalysis;

    /**
     * 统计周期
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "stat_period", length = 20)
    private StatPeriod statPeriod;

    /**
     * 周期开始时间
     */
    @Column(name = "period_start_time")
    private LocalDateTime periodStartTime;

    /**
     * 周期结束时间
     */
    @Column(name = "period_end_time")
    private LocalDateTime periodEndTime;

    /**
     * 统计版本
     */
    @Column(name = "stat_version", length = 20)
    private String statVersion;

    /**
     * 数据来源
     */
    @Column(name = "data_source", length = 100)
    private String dataSource;

    /**
     * 计算方法
     */
    @Column(name = "calculation_method", length = 100)
    private String calculationMethod;

    /**
     * 统计参数
     */
    @Column(name = "stat_params", columnDefinition = "TEXT")
    private String statParams;

    /**
     * 扩展属性
     */
    @Column(name = "extended_attributes", columnDefinition = "TEXT")
    private String extendedAttributes;

    /**
     * 备注信息
     */
    @Column(name = "remarks", length = 500)
    private String remarks;

    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

    /**
     * 版本号
     */
    @Version
    @Column(name = "version", nullable = false)
    private Long version = 0L;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;

}